package dao

import (
	"WORKSPACE/models"
	"fmt"
)

func GetAllwdata() (error, []models.Wdata, int64) {
	var WdataData []models.Wdata
	//AttendanceData := []models.Attendance{{"1qwe",1,"1",1,1,1,1,1,}}
	var total int64
	fmt.Println(WdataData)
	err := db.Table("wdata").Order("Eno ASC").Count(&total).Find(&WdataData).Error
	fmt.Println(WdataData)
	return err, WdataData, total
}

func Addwdata(wdata models.Wdata) error {
	err := db.Table("wdata").Create(&wdata).Error
	return err
}

func Updatewdata(wdata models.Wdata) error {
	err := db.Table("wdata").Where("Eno = ? AND wdata = ?", wdata.Eno,wdata.Wdata).Updates(wdata).Error
	return err
}

func Delwdata(eno string,wdata string) error {
	err := db.Table("wdata").Where("Eno = ? AND wdata = ?", eno,wdata).Delete(models.Wdata{}).Error
	return err
}